<template>
	<view class="viewed">
		<item-list :ItemObj="viewedList" event="event" desc="删除记录" path="/my" text="历史浏览" @event="resolve"
			:num="getViewedNum" />
	</view>
</template>
<script>
	import ItemList from "components/common/Items/ItemList";
	import {
		mapGetters,
		mapMutations,
		mapState
	} from "vuex";

	export default {
		components: {
			ItemList
		},
		data() {
			return {
				viededObj: null,
				num: 0,
			};
		},
		computed: {
			...mapGetters(["getViewedNum"]),
			...mapState(["viewedList"]),
		},
		methods: {
			...mapMutations(["deleteViewedData"]),
			resolve(goodsList) {


				uni.showModal({
					title: "提示",
					content: `确认删除?`,
					showCancel: true,
					confirmText: "确定",
					success: async (res) => {
						if (res.confirm) {
							goodsList.forEach((good) => {
								this.deleteViewedData(good);
							});
							this.success("删除成功");
						} else {
							this.info('已取消');
						}
					},
				})

			},
		},
	};
</script>
<style lang="scss" scoped>
	.viewed {
		width: 100vw;
		background-color: rgb(242, 242, 242);
	}
</style>
